<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>
<!-- 一个密码输入框，带有一个按钮用于切换显示或隐藏密码文本。 参考 https://www.jq22.com/yanshi374 -->

<body>
    <div id="app">
        <input type="password" v-model="password" v-if="!show">
        <input type="text" v-model="password" v-if="show">
        <button @click="add">{{ show? '隐藏密码' : '显示密码' }}</button>
    </div>

</body>
<script>
    const { createApp, ref } = Vue;

    createApp({
        setup() {
            const password = ref('');
            const show = ref(false);

            function add() {
                show.value = !show.value;
            }
            return {
                password,
                show,
                add
            }
        }
    }).mount('#app')
</script>

</html>